#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
    int n, k; std::cin >> n >> k;
    int tmp = 0;
    int ans = 0;
    for(int i = 0; i < k - 1; ++i){
        cin >> tmp;
        ans += (i+1)*tmp;
    }
    for(int i = k - 1; i < n - k + 1; ++i){
        cin >> tmp;
        ans += k*tmp;
    }
    for(int i = n - k + 1; i < n; ++i){
        cin >> tmp;
        ans += (n - i)*tmp;
    }
    cout << ans;
    return 0;
}

// #include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main1() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    ll window = 0, ans = 0;
    for (int i = 0; i < k; ++i) window += a[i];
    ans += window;

    for (int i = k; i < n; ++i) {
        window += a[i] - a[i - k];
        ans += window;
    }

    cout << ans << '\n';
    return 0;
}